import axios from 'axios';

export async function getRoleList(roleName,roleDesc,pageNo=1,pageSize=10){
    let resp = await axios.get('api/pet_sys/role.do',{
        params:{
            roleName,
            roleDesc,
            pageNo,
            pageSize
        }
    })
    return resp;
}

export async function getAllRoles(){
    let resp = await axios.get('api/pet_sys/role.do',{
        params:{
            method:'getAllRoles',
        }
    })
    return resp;
}

export async function hasAuthority(roleId, transferValue) {
    let resp = await axios.get('api/pet_sys/role.do', {
        params:{
            method: 'hasAuthority',
            roleId,
            authorityIds: transferValue
        }
    })
    return resp;
}

export async function getAuthority(roleId){
    let resp = await axios.get('api/pet_sys/role.do',{
        params:{
            method:'getAuthority',
            roleId
        }
    })
    return resp;
}


export async function deleteRole(roleId){
    let resp = await axios.get('api/pet_sys/role.do',{
        params:{
            method:'deleteRole',
            roleId,
        }
    })
    return resp;
}

export async function addRole(ruleForm){
    let resp = await axios.get('api/pet_sys/role.do',{
        params:{
            method:'addRole',
            roleName:ruleForm.roleName,
            roleDesc:ruleForm.roleDesc,
        }
    })
    return resp;
}

export async function updateRole(id,ruleForm){
    let resp = await axios.get('api/pet_sys/role.do',{
        params:{
            method:'updateRole',
            roleId:id,
            roleName:ruleForm.roleName,
            roleDesc:ruleForm.roleDesc,
        }
    })
    return resp;
}